package com.xiaowan.user.controller;

import com.xiaowan.user.entity.User;
import com.xiaowan.user.service.UserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userservice;

    @RequestMapping("/ceshi")
    public String ceshi(){
        return "ceshi";
    }

    @RequestMapping("/home")
    @RequiresPermissions("user:home")
    public String home(){
        return "home";
    }

    @RequestMapping("/finduser")
    @ResponseBody
    public User find(HttpServletRequest request){
        String username = request.getParameter("username");
        User user = userservice.findUserByUserName(username);
        return user;
    }
}
